package vfs.dao;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "VFSNODE", schema = "PUBLIC")
public class VFSNode {

    @Id
    @Column(name = "id")
    private long id;

    @Column(name = "nodename")
    private String name;

    @Column(name = "parent")
    private long parent;



    /**
     * Create a new VFSNode.
     * @param name
     * @param parent
     */
    public VFSNode(final String name, final long parent) {
        this.name = name;
        this.parent = parent;
    }

    public final long getId() {
        return this.id;
    }

    public final void setId(final long id) {
        this.id = id;
    }

    public final String getName() {
        return name;
    }

    public final void setName(final String name) {
        this.name = name;
    }

    public final long getParent() {
        return parent;
    }

    public final void setParent(final long parent) {
        this.parent = parent;
    }


    /* mappedBy value is instance variable in VFSPath */
    @OneToMany(mappedBy = "ancestor",
            targetEntity = VFSPath.class,
            fetch = FetchType.EAGER,
            orphanRemoval = true)
    private List<VFSPath> pathList;

    public final List<VFSPath> getPathList() {
        return pathList;
    }

}
